package com.jic.manager.controller.manage.memstorecontroller;

import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.manager.entity.MestoreSupplier;
import com.jic.manager.service.MestoreSupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("storeSupplier")
public class MemStoreSupplierController {
    @Autowired
    private MestoreSupplierService mestoreSupplierService;
    //新增修改供应商
    @PostMapping(value = "/saveSupplierInfo")
    public RestResult<String> saveSupplierInfo(@RequestBody MestoreSupplier memStoreSupplier){
        return mestoreSupplierService.saveSupplierInfo(memStoreSupplier);
    }

    //查询供应商列表
    @PostMapping(value = "/getSupplierList")
    @ResponseBody
    public RestResult<List<MestoreSupplier>> getSupplierList(@RequestBody MestoreSupplier memStoreSupplier){
        memStoreSupplier.setDeleteFlag(0);
        List<MestoreSupplier> supplierList = mestoreSupplierService.query(memStoreSupplier);
        return RestResult.success(supplierList);
    }


    //删除供应商
    @PostMapping(value = "/delSupplierInfo")
    public RestResult<String> delSupplierInfo(@RequestBody MestoreSupplier mestoreSupplier){
        return mestoreSupplierService.delSupplierInfo(mestoreSupplier.getId());
    }

    //启用停用按钮
    @PostMapping(value = "/upSupplierStatus")
    @ResponseBody
    public RestResult<String> upSupplierStatus(@RequestBody MestoreSupplier mestoreSupplier){
        return mestoreSupplierService.upSupplierStatus(mestoreSupplier);
    }

    //查询供应商详情
    @PostMapping(value = "/getSupplierInfo")
    public  RestResult<MestoreSupplier> getSupplierInfo(@RequestBody MestoreSupplier mestoreSupplier){

        return  mestoreSupplierService.getSupplierInfo(mestoreSupplier);
    }
}
